﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using _02.建造者模式.Builders;
using _02.建造者模式.Entities;

namespace _02.建造者模式
{
    /// <summary>
    /// 建造者模式 - Builder Pattern
    /// 适用场景：创建复杂对象，比如套餐模板、大包模板
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            DbSession dbSession=new DbSession();
            dbSession.Database.CreateIfNotExists();
            Console.WriteLine("OK");
            Console.ReadKey();


            //01.实例化套餐建造者
            MealBuilder mealBuilder = new MealBuilder("测试套餐");

            //02.创建套餐必选商品
            List<Product> requiredProducts = new List<Product>();
            mealBuilder.BuildRequiredProducts(requiredProducts);

            //03.创建套餐升级商品
            Dictionary<Product, decimal> upGradedProducts = new Dictionary<Product, decimal>();
            mealBuilder.BuildUpGradedProducts(upGradedProducts);

            //04.创建套餐可选商品
            List<Product> choosableProducts = new List<Product>();
            mealBuilder.BuildChoosableProducts(choosableProducts);

            //05.创建套餐
            Meal newMeal = mealBuilder.Build();
        }
    }
}
